#include "fileitem.h"
#include "ui_fileitem.h"

FileItem::FileItem(const QString &filePath,QWidget *parent) :
    QWidget(parent),
    filePath(filePath),
    ui(new Ui::FileItem)
{
    ui->setupUi(this);
    QFileInfo fileInfo(filePath);
    QString suffix = fileInfo.suffix();
    ui->fileImg_LB->setStyleSheet(QString(
        "#fileImg_LB{"
            "border-image:url(':/background/imagesRes/%1.png') 0 0 0 0 stretch stretch;"
        "}").arg(getFileTypeImg(suffix)));
    ui->fileName_LB->setText(fileInfo.fileName());
    ui->fileSize_LB->setText(unitConversion(fileInfo.size()));
    connect(ui->delete_BT,&QPushButton::clicked,[this](){
        emit fileItemDelete(this);
    });
}

FileItem::~FileItem()
{
    delete ui;
}
QString FileItem::getFilePath(){
    return filePath;
}
